﻿using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Windows;
using VMDS.Business.Entities;

namespace VMDS.GUIClient.Model
{
    public class ManagerDataStore:INotifyPropertyChanged
    {
        private ObservableCollection<VM> _vms;
        public  ObservableCollection<VM> VMs
        {
            get { return _vms; }
            set { _vms = value;
                OnProp("VMs");
            }
        }

        private VM _vm;
        public VM CurrentVM
        {
            get { return _vm; }
            set
            {
                _vm = value;
                OnProp("CurrentVM");
            }
        }

        private ObservableCollection<OS> _oses;
        public ObservableCollection<OS> OSs
        {
            get { return _oses; }
            set { _oses = value; OnProp("OSs"); }
        }

        private ObservableCollection<ScreenShot> _scrs;
        public  ObservableCollection<ScreenShot> ScreenShots
        {
            get { return _scrs; }
            set { _scrs = value;
                OnProp("ScreenShots");
            }
        }
        public  ObservableCollection<ClientPC> ClientPCs { get; set; }
        public  ObservableCollection<Task> Tasks
        {
            get { return _t; }
            set { _t = value;
                OnProp("Tasks");
            }
        }
        public  ObservableCollection<Subject> Subjects { get; set; }

        private string _unc;
        public string ShareUNC
        {
            get { return _unc; }
            set { _unc = value;
                OnProp("ShareUNC");
            }
        }
        
        private static ManagerDataStore _inst;
        private ObservableCollection<Task> _t;

        public static ManagerDataStore Instance
        {
            get { return _inst ?? (_inst=new ManagerDataStore()); }
        }
        static ManagerDataStore()
        {
            _inst = new ManagerDataStore();
        }

        public void LoadData()
        {
            var ms = ServiceLocator.MainService;
            Instance.OSs=new ObservableCollection<OS>(ms.GetOSs());
            //ShareUNC = MsLocator.Client.GetNetStorage();
          
            Instance.Tasks = new ObservableCollection<Task>(ms.GetAllTasks());
            Instance.ClientPCs = new ObservableCollection<ClientPC>(ms.GetPCs());
            Instance.VMs = new ObservableCollection<VM>(ms.GetVMs());
            //ScreenShots = new ObservableCollection<ScreenShot>(MsLocator.Client.GetScreenShots());
           
        }

       

        void OnProp(string name)
        {
            if (PropertyChanged!=null) PropertyChanged(this,new PropertyChangedEventArgs(name));
        }
        public event PropertyChangedEventHandler PropertyChanged;
    }
}
